package com.ipan.weixin.msg.user;

import java.util.ArrayList;
import java.util.List;

import com.ipan.weixin.msg.AbstractJsonMsg;

/**
 * 查询所有分组消息
 * 
 * @author iPan
 * @version 2013-12-26
 */
public class GroupsMsg extends AbstractJsonMsg{

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -7579568631565200082L;

	private List<GroupBean> groups;
	
	public synchronized void check() {
		if (groups == null) {
			groups = new ArrayList<GroupBean>();
		}
	}
	
	public void addGroup(GroupBean bean) {
		check();
		this.groups.add(bean);
	}
	
	public void addGroup(Integer id, String name) {
		check();
		this.groups.add(new GroupBean(id, name));
	}
	
	public void addGroup(Integer id, String name, Integer count) {
		check();
		this.groups.add(new GroupBean(id, name, count));
	}

	public List<GroupBean> getGroups() {
		return groups;
	}

	public void setGroups(List<GroupBean> groups) {
		this.groups = groups;
	}
	
//	public static void main(String[] args) {
//		String json = "{\"groups\": [{\"id\": 0, \"name\": \"未分组\", \"count\": 72596}, {\"id\": 1, \"name\": \"黑名单\", \"count\": 36}]}";
//		GroupsMsg msg = fromJson(json, GroupsMsg.class);
//		System.out.println(msg);
//	}
}
